package BookManagement.service;

import BookManagement.dao.PurchaseDao;
import BookManagement.domain.Purchase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service("purchaseService")
public class PurchaseServiceImpl implements PurchaseService{
    @Autowired
    PurchaseDao purchaseDao;
    @Override
    public int purchase(Purchase purchase){
        return purchaseDao.purchase(purchase);
    }

    @Override
    public List<Purchase> findAllPurchase(HashMap<String,Object> map){
        return purchaseDao.findAllPurchase(map);
    }

    @Override
    public List<Purchase> findAllPurchaseByBook(HashMap<String,Object> map){
        return purchaseDao.findAllPurchaseByBook(map);
    }

    @Override
    public List<Purchase> findAllPurchaseByUser(HashMap<String,Object> map){
        return purchaseDao.findAllPurchaseByUser(map);
    }

    @Override
    public int findPurchaseCountByUser(String username){
        return purchaseDao.findPurchaseCountByUser(username);
    }

    @Override
    public int findPurchaseCountByBook(String bookISBN){
        return purchaseDao.findPurchaseCountByBook(bookISBN);
    }

    @Override
    public int deletePurchase(String bookISBN,String username){
        return purchaseDao.deletePurchase(bookISBN,username);
    }
}
